import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
/**
 * 
 * @author Francisco
 *
 */
public class ClienteRead extends Thread {
	
	Socket cliente;
	public ClienteRead( Socket cliente) {
	
		this.cliente = cliente;
	}
		@Override
	public void run() {
			try 
			{
				PrintWriter salidaAlServer = new PrintWriter(
						cliente.getOutputStream(), true);
				salidaAlServer.println("Read");
				
				BufferedReader entradaDesdeElServer = new BufferedReader(
						new InputStreamReader(cliente.getInputStream()));
				do {
					String mensaje = entradaDesdeElServer.readLine();
					if(mensaje != null){
//				Evitar que llegue aqui a tiempo
						System.out.println(mensaje);
					}else{
						entradaDesdeElServer.close();
						salidaAlServer.close();
					}
				} while (!cliente.isClosed());
				System.out.println("salidita 1 ");
			} catch (IOException e) {
				System.out.println("salidita 2");
			}
	}
	
}
